import requests

# 目标URL
url = "https://mp.weixin.qq.com/mp/appmsgalbum"

# 请求参数
params = {
    "action": "getalbum",
    "__biz": "Mzg3NzcxNzEwMA==",
    "album_id": "3561561924963844100",
    "count": "100",
    "begin_msgid": "2247522189",
    "begin_itemidx": "1",
    "f": "json"
}

# 浏览器User-Agent头
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
}

try:
    # 发送GET请求
    response = requests.get(url, params=params, headers=headers)
    
    # 检查请求是否成功
    if response.status_code == 200:
        # 打印响应内容
        print("请求成功！")
        print("响应内容:", response.text)
        
        # 如果需要解析JSON
        data = response.json()
        links=[]
        for i in range(len(data["getalbum_resp"]["article_list"])):
            print(str(i+1)+"."+data["getalbum_resp"]["article_list"][i]["title"])
            url=data["getalbum_resp"]["article_list"][i]["url"]
            secure_url = url.replace("http://", "https://")
            links.append(secure_url)
        choice = int(input("请输入要查看的文章"))
        import getpage
        getpage.GetPassage(links[choice])
    else:
        print(f"请求失败，状态码: {response.status_code}")
        
except requests.exceptions.RequestException as e:
    print(f"请求发生错误: {e}")
